<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>站主注册</title>
</head>
<link rel="stylesheet" href="css/modules/code.css">
<link rel="stylesheet" href="css/modules/laydate/default/laydate.css">
<link rel="stylesheet" href="css/modules/layer/default/layer.css">
<link rel="stylesheet" href="css/layui.css">
<link rel="stylesheet" href="css/backRegistered.css">

<body>
  <form id="backregisterForm">
<div id="back_reistereds">

    <div id="back_reistereds_farme">
        <p id="back_reister_p1">
            站主注册
        </p>
        <p id="reister_p2">
            <input type="text" id="back_user" name="back_user" required lay-verify="required" placeholder="输入注册账号" autocomplete="off" class="layui-input">    
        </p>
        
        <p id="reister_p3">
            <input type="text" id="back_pwd" name="back_pwd" required lay-verify="required" placeholder="输入注册密码" autocomplete="off" class="layui-input"> 
        </p>
        <p id="reister_p4">
            <input type="text" id="back_conpwd" name="back_conpwd" required lay-verify="required" placeholder="输入注册密码" autocomplete="off" class="layui-input">     
        </p>
        <button type="button" id="back_gologin"class="layui-btn layui-btn-radius layui-btn-primary" onclick="backregister()">确认注册</button>
        <button type="button" id="back_gocancle"class="layui-btn layui-btn-radius layui-btn-primary" onclick="quters()">取消</button>
    
    </div><!-- reistereds_farme -->  
</form>
</body>
<script src="js/jquery-3.6.0.min.js"></script>
<script>

function quters(){
    window.location.href = '/'
}
//站主注册
function backregister(){
    let username = $('#back_user').val();
        let password = $('#back_pwd').val();
        let confirmPassword = $('#back_conpwd').val();
        if (username.length > 0 && password.length > 0 && password === confirmPassword) {
            $.ajax({
                url: "/backregisterDone",
                type: "POST",
                data: $('#backregisterForm').serialize(),
                dataType: "json",
                success: function (res) {
                    if (res.code === 200) {
                        window.location.href = "/backlogin";
                    }
                }
            })
        } else {
            alert('请输入正确的账号或密码')
        }
    }
    </script>
</html>